home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Playboy Electronic Datebook
/
Playboy Electronic Datebook - Disk 1.img
/
VERSION.MS_
/
VERSION.MS
Wrap
Text File
|
1993-10-22
|
12KB
|
335 lines
'$IFDEF VERSION
'**
'** Purpose:
'** Version checking...
'**
'**
'** Arguments:
'** szDest$ - Destination of the files to be installed
'** szIni$ - Ini file which contains the version info.
'** szIniSect$ - Section of the ini file that contains the verion info.
'** Returns:
'**
'*************************************************************************
FUNCTION Version (szDest$, szIni$, szIniSect$) STATIC AS INTEGER
DIM rVerInfo AS VERSION
Cursor% = ShowWaitCursor()
VER_FILELIST$ = "ThemeFiles"
nItems% = MakeListIniKeys(szIni$, szIniSect$)
FOR i% = 1 TO nItems% STEP 1
rVerInfo.FileName = RTRIM$(GetListItem(VER_FILELIST$,i%))
szVerList$ = GetIniKeyString(szIni$, szIniSect$,RTRIM$(rVerInfo.FileName))
rVerInfo.InitVer = GetNthFieldFromIniString(szVerList$, INIT_VER_POS)
rVerInfo.CurVer = GetNthFieldFromIniString(szVerList$, CUR_VER_POS)
iItem% = PAR_FILE_POS ''position of the first parent filename
WHILE (TRUE)
szParFile$ = GetNthFieldFromIniString(szVerList$, iItem%)
IF LEN(szParFile$) = 0 THEN
EXIT WHILE
ELSE
iItem% = iItem% + 1
IF DoesFileExist(MakePath(szDest$,szParFile$),femRead) THEN
szParInit$ = GetFileInitVer(MakePath(szDest$,szParFile$))
szParCur$ = GetFileCurVer(MakePath(szDest$,szParFile$))
IF (LEN(szParInit$) <> 0) OR (LEN(szParCur$) <> 0) THEN
IF INSTR(rVerInfo.FileName, szParFile$) > 0 THEN
iResult% = TestDupe(rVerInfo.InitVer, rVerInfo.CurVer, szParInit$,szParCur$)
ELSE
iResult% = TestRange(rVerInfo.InitVer, rVerInfo.CurVer, szParInit$,szParCur$)
END IF
IF (iResult% = -1) THEN
iRC% = DoMsgBox(MSG_THE_FILE + RTRIM$(rVerInfo.FileName) + VERSION_APPFILE_NC + MakePath(szDest$,szParFile$) + VERSION_APPFILE_OLD, VERSION_CAPTION, MB_ICONHAND+MB_TASKMODAL+MB_OK)
AddListItem BadFileList$, RTRIM$(rVerInfo.FileName)
EXIT WHILE
ELSEIF (iResult% = 1) THEN
'' Do we notify user that the install file is newer than the parent???
END IF
ELSE
EXIT WHILE ''something went wrong getting the parent versions
END IF
END IF
END IF
WEND
NEXT i%
VERSION = 0
IF GetListLength(VER_FILELIST$) <> 0 THEN
RemoveSymbol VER_FILELIST$
END IF
RestoreCursor Cursor%
END FUNCTION
'**
'** Purpose:
'** Content Version checking...
'** For each theme pack listed in the Amaze.ini, the theme.dll will be check as a child
'** against the files listed in the szIniSect$ of the szIni$ file.
'** If the theme is older or newer that the files being installed, a message will pop up.
'**
'** Arguments:
'** szDest$ - Destination of the files to be installed
'** szIni$ - Ini file which contains the version info.
'** szIniSect$ - Section of the ini file that contains the verion info for the content.
'** Returns:
'**
'*************************************************************************
FUNCTION ContentVersion (szDest$, szIni$, szIniSect$) STATIC AS INTEGER
DIM rVerInfo AS VERSION
bBadTheme% = 0
Cursor% = ShowWaitCursor()
VER_FILELIST$ = "ThemeFiles"
nItems% = MakeListIniKeys(szIni$, szIniSect$)
FOR t% = 1 TO iMaxNumTP% STEP 1
IF DoesIniKeyExist(ini$, INI_SEC_THEME_PACKS, INI_KEY_TP+LTRIM$(STR$(t%)) ) = 1 THEN
szTheme$ = GetIniKeyString( ini$, INI_SEC_THEME_PACKS, INI_KEY_TP+LTRIM$(STR$(t%)) )
IF (bDDDInData%) THEN
szDDDFile$ = INI_KEY_DATA
ELSE
szDDDFile$ = INI_KEY_MASTER
END IF
IF DoesIniKeyExist(ini$, szTheme$, szDDDFile$) THEN
szThemeDllPath$ = GetIniKeyString(ini$, szTheme$, szDDDFile$)
IF DoesFileExist(szThemeDllPath$, femRead) THEN
rVerInfo.FileName = szThemeDllPath$
szStrBuf$ = STRING$(20,32)
iRC% = ReadStrResource(RTRIM$(rVerInfo.FileName), IDS_THEMEPACK_DLL_VERSION, szStrBuf$, LEN(szStrBuf$))
rVerInfo.InitVer = szStrBuf$
rVerInfo.CurVer = szStrBuf$
FOR i% = 1 TO nItems% STEP 1
szFileName$ = RTRIM$(GetListItem(VER_FILELIST$,i%))
szVerList$ = GetIniKeyString(szIni$, szIniSect$,RTRIM$(szFileName))
szInitVer$ = GetNthFieldFromIniString(szVerList$, INIT_VER_POS)
szCurVer$ = GetNthFieldFromIniString(szVerList$, CUR_VER_POS)
IF (DoesFileExist(MakePath(szDest$,szFileName$),femRead) = 1) THEN
IF (LEN(szInitVer$) <> 0) OR (LEN(szCurVer$) <> 0) THEN
iResult% = TestRange(rVerInfo.InitVer, rVerInfo.CurVer, szInitVer$, szCurVer$)
IF (iResult% <> 0) THEN
iRC% = DoMsgBox(szTheme$ + VERSION_BAD_CONTENT, VERSION_CAPTION, MB_ICONHAND+MB_TASKMODAL+MB_OK)
bBadTheme% = 1
EXIT FOR
END IF
END IF
END IF
NEXT i%
END IF
END IF
END IF
NEXT t%
ContentVersion = bBadTheme%
IF GetListLength(VER_FILELIST$) <> 0 THEN
RemoveSymbol VER_FILELIST$
END IF
RestoreCursor Cursor%
END FUNCTION
'**
'** GetFileInitVer()
'**
'** Purpose:
'**
'** Arguments:
'**
'** Returns:
'**
'*************************************************************************
FUNCTION GetFileInitVer(szFile$) STATIC AS STRING
DIM szStrBuf$
szStrBuf$ = STRING$(20,32)
iRC% = ReadStrResource(szFile$, IDS_INITIAL_VERSION, szStrBuf$, LEN(szStrBuf$))
GetFileInitVer = szStrBuf$
END FUNCTION
'**
'** GetFileCurVer()
'**
'** Purpose:
'**
'** Arguments:
'**
'** Returns:
'**
'*************************************************************************
FUNCTION GetFileCurVer(szFile$) STATIC AS STRING
DIM szStrBuf$
szStrBuf$ = STRING$(20,32)
iRC% = ReadStrResource(szFile$, IDS_CURRENT_VERSION, szStrBuf$, LEN(szStrBuf$))
GetFileCurVer = szStrBuf$
END FUNCTION
'**
'** TestRange()
'**
'** Purpose:
'** Compares initial and current version strings of a file
'** to init and cur verions of its parent file.
'**
'** Arguments:
'** Init and Cur version strings of child and parent
'**
'** Returns:
'** Integer:
'** -1 if existing parent file is newer
'** 0 if file is in range
'** 1 if file is newer than parent file
'**
'*************************************************************************
FUNCTION TestRange(szChildInitVer AS STRING, szChildCurVer AS STRING,szParInitVer AS STRING,szParCurVer AS STRING) STATIC AS INTEGER
''PRINT "In TestRange..."
''PRINT "szChildInitVer = " + szChildInitVer
''PRINT "szChildCurVer = " + szChildCurVer
''PRINT "szParInitVer = " + szParInitVer
''PRINT "szParCurVer = " + szParCurVer
iChildInitMaj% = VAL(MID$(szChildInitVer,1,2))
iChildCurMaj% = VAL(MID$(szChildCurVer,1,2))
iChildInitMin% = VAL(MID$(szChildInitVer,4,2))
iChildCurMin% = VAL(MID$(szChildCurVer,4,2))
iParInitMaj% = VAL(MID$(szParInitVer,1,2))
iParCurMaj% = VAL(MID$(szParCurVer,1,2))
iParInitMin% = VAL(MID$(szParInitVer,4,2))
iParCurMin% = VAL(MID$(szParCurVer,4,2))
'$IFDEF DEBUG
iChildInitBeta% = 0 ''VAL(MID$(szChildInitVer,7,3))
iChildCurBeta% = VAL(MID$(szChildCurVer,7,3))
iParInitBeta% = 0 ''VAL(MID$(szParInitVer,7,3))
iParCurBeta% = VAL(MID$(szParCurVer,7,3))
'$ENDIF
IF iChildInitMaj% > iParCurMaj% THEN
TestRange = 1
''PRINT "iChildInitMaj%="+STR$(iChildInitMaj%)+" > iParCurMaj%="+STR$(iParCurMaj%)
GOTO END_TESTRANGE
ELSEIF iChildCurMaj% < iParInitMaj% THEN
TestRange = -1
''PRINT "iChildCurMaj% < iParInitMaj%"
GOTO END_TESTRANGE
ELSE ''child in range of parent
IF iChildInitMin% > iParCurMin% THEN
TestRange = 1
''PRINT "iChildInitMin% > iParCurMin%"
GOTO END_TESTRANGE
ELSEIF iChildCurMin% < iParInitMin% THEN
TestRange = -1
''PRINT "iChildCurMin% < iParInitMin%"
GOTO END_TESTRANGE
'$IFDEF DEBUG
ELSE ''child in range of parent
IF iChildInitBeta% > iParCurBeta% THEN
TestRange = 1
''PRINT "iChildInitBeta% > iParCurBeta%"
GOTO END_TESTRANGE
ELSEIF iChildCurBeta% < iParInitBeta% THEN
TestRange = -1
''PRINT "iChildCurBeta% < iParInitBeta%"
GOTO END_TESTRANGE
ELSE
TestRange = 0
GOTO END_TESTRANGE
END IF ''Beta
'$ENDIF
END IF ''Minor
TestRange = 0
END IF ''major
''PRINT "TestRange = 0"
TestRange = 0
END_TESTRANGE:
END FUNCTION
'**
'** TestDupe()
'**
'** Purpose: Avoid overwriting a newer version of the same file
'** Compares initial and current version strings of a file
'** to init and cur verions of its duplicate file.
'**
'** Arguments:
'** Init and Cur version strings of child and parent should be same file
'**
'** Returns:
'** Integer:
'** -1 if existing parent file is newer
'** 0 if file is in range
'** 1 if new file is newer than existing file
'**
'*************************************************************************
FUNCTION TestDupe(szChildInitVer AS STRING, szChildCurVer AS STRING,szParInitVer AS STRING,szParCurVer AS STRING) STATIC AS INTEGER
iChildInitMaj% = VAL(MID$(szChildInitVer,1,2))
iChildCurMaj% = VAL(MID$(szChildCurVer,1,2))
iChildInitMin% = VAL(MID$(szChildInitVer,4,2))
iChildCurMin% = VAL(MID$(szChildCurVer,4,2))
iParInitMaj% = VAL(MID$(szParInitVer,1,2))
iParCurMaj% = VAL(MID$(szParCurVer,1,2))
iParInitMin% = VAL(MID$(szParInitVer,4,2))
iParCurMin% = VAL(MID$(szParCurVer,4,2))
IF iChildCurMaj% < iParCurMaj% THEN
TestDupe = -1
''PRINT "iChildInitMaj%="+STR$(iChildInitMaj%)+" > iParCurMaj%="+STR$(iParCurMaj%)
GOTO END_TESTDUPE
ELSEIF iChildCurMaj% = iParCurMaj% THEN ''child in range of parent
IF iChildCurMin% < iParCurMin% THEN
TestDupe = -1
''PRINT "iChildInitMin% > iParCurMin%"
GOTO END_TESTDUPE
END IF ''Minor
TestDupe = 0
END IF ''major
TestDupe = 0
END_TESTDUPE:
END FUNCTION
'$ENDIF ''ifdef VERSION